// This file contains course-related API functions
import type {
    GetCourseCategoriesData,
    GetCourseCategoriesResponses,
    GetCourseDetailData,
    GetCourseDetailResponses,
    GetCourseListData,
    GetCourseListResponses
} from './courseTypes';
import {client as _heyApiClient} from '../../api/client.gen';
import type {Options} from '../common/apiTypes';

/**
 * 获取课程列表
 * 分页获取课程列表，包含课程标题、价格、难度等级、时长等信息
 */
export const getCourseList = <ThrowOnError extends boolean = false>(options?: Options<GetCourseListData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetCourseListResponses, unknown, ThrowOnError>({
        url: '/api/courses',
        ...options
    });
};

/**
 * 获取课程详情
 * 根据ID获取课程详情
 */
export const getCourseDetail = <ThrowOnError extends boolean = false>(options: Options<GetCourseDetailData, ThrowOnError>) => {
    return (options.client ?? _heyApiClient).get<GetCourseDetailResponses, unknown, ThrowOnError>({
        url: '/api/courses/{id}',
        ...options
    });
};

/**
 * 获取课程分类
 * 获取所有课程难度等级作为分类选项
 */
export const getCourseCategories = <ThrowOnError extends boolean = false>(options?: Options<GetCourseCategoriesData, ThrowOnError>) => {
    return (options?.client ?? _heyApiClient).get<GetCourseCategoriesResponses, unknown, ThrowOnError>({
        url: '/api/courses/categories',
        ...options
    });
};